package org.exez.modules.visitor.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.exez.common.api.vo.Result;
import org.exez.common.constant.CommonConstant;
import org.exez.common.exception.JeecgBootException;
import org.exez.common.system.query.QueryGenerator;
import org.exez.common.aspect.annotation.AutoLog;
import org.exez.common.system.vo.LoginUser;
import org.exez.common.util.DateUtils;
import org.exez.common.util.PasswordUtil;
import org.exez.common.util.oConvertUtils;
import org.exez.modules.system.entity.SysUser;
import org.exez.modules.system.vo.SysUserSaveVO;
import org.exez.modules.visitor.constant.AuthorityEnum;
import org.exez.modules.visitor.entity.Institution;
import org.exez.modules.visitor.entity.PolicePay;
import org.exez.modules.visitor.service.IInstitutionService;
import org.exez.modules.visitor.service.IPolicePayService;
import java.util.Date;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.exez.common.system.base.controller.JeecgController;
import org.exez.modules.visitor.vo.PolicePaySaveVO;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @Description: 公安pay
 * @Author: exez-boot
 * @Date:   2020-08-19
 * @Version: V1.0
 */
@Slf4j
@Api(tags="公安pay")
@RestController
@RequestMapping("/visitor/policePay")
public class PolicePayController extends JeecgController<PolicePay, IPolicePayService> {
	@Autowired
	private IPolicePayService policePayService;

	@Autowired
	IInstitutionService iInstitutionService;

	@PostMapping(value = "/addPolicePay")
	@ApiOperation(value = "添加公安PAY", notes = "添加公安PAY")
	public Result<String> addPolicePay(@Validated @RequestBody PolicePaySaveVO policePaySaveVO) {
		LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		String authority = sysUser.getAuthority();
		String id = sysUser.getId();
		PolicePay policePay = new PolicePay();
		//Institution byId = iInstitutionService.getById(policePaySaveVO.getInstitutionId());
		try {
			BeanUtils.copyProperties(policePaySaveVO,policePay);
			policePay.setCreateBy(id);
			policePay.setUpdateBy(id);
			int isScan = policePayService.insertPolicePay(policePay);
			if(isScan == 0){
				policePayService.policePay(policePay);
			}
		}catch (Exception e){
			return Result.ok("处理成功！");
		}


		return Result.ok("处理成功！");

	}



}
